package com.gs.api.config.api;

import cn.hutool.core.lang.Snowflake;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author guoyunfei on 2021/10/10 14:49
 * @className SnowflakeConfig
 * @description TODO
 * @Version 1.0
 */
@Configuration
@AllArgsConstructor
public class SnowflakeConfig {

    private final ApiConfig apiConfig;

    @Bean
    public Snowflake snowflake() {
        return new Snowflake(apiConfig.getWorkerId(), apiConfig.getDatacenterId());
    }

}
